package com.geoway.adf.report;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.util.StringUtils;

/**
 * @Author: lzw
 * @Date: 2024/1/12 14:47
 * @Description:
 */
@EnableJpaAuditing
@SpringBootApplication
public class ReportApplication {
    private static String contextPathKey = "server.servlet.context-path";
    public static void main(String[] args) {
        ConfigurableApplicationContext application = SpringApplication.run(ReportApplication.class, args);
        Environment env = application.getEnvironment();
        String port = env.getProperty("server.port");
        String path = "";
        if(env.containsProperty(contextPathKey)){
            String value = env.getProperty(contextPathKey);
            if(StringUtils.hasText(value) && !"/".equals(value.trim())){
                path = value;
            }
        }
        System.out.print("\n\t----------------------------------------------------------\n\t" +
                "ADF Report is running! Access URL:\n\t" +
                "Local: \t\thttp://localhost:" + port + path + "/designer\n\t" +
                "----------------------------------------------------------");
    }
}
